package com.pan.action.chain.impl;

import com.pan.action.chain.ChainAction;
import com.pan.show.record.Record;
import com.pan.utils.ApplicationConfig;
import com.pan.utils.ShortcutKeyConfig;

import java.util.Set;

public class GlobalQuitAction extends ChainAction<Set<String>> {
    public GlobalQuitAction() {
    }

    private String[] targetKeys;{
        String shortcutKey = ShortcutKeyConfig.INSTANCE.getQuitKey();
        targetKeys = shortcutKey.trim().split("\\+");
    }

    @Override
    public void handle(Set<String> keys) {
        for (String k:targetKeys){
            if (!keys.contains(k)) return;
        }

        Record record = ApplicationConfig.INSTANCE.getRecordFactory().getRecord();
        record.setContent("my-measuring end");
        System.out.println("my-measuring end");
        record.display();
        System.exit(0);
    }
}
